<template>
    <div class="basc-info-card">
        <div class="mb-box-cell">
            <div class="flex_between">
                <div class="flex_row">
                    <div class="obj-gdimg-box">
                        <img :src="gdInfo.img" alt="" class="obj-avatar">
                    </div>
                    <div class="obj-info ml10">
                        <div class="bold font_size14">{{ gdInfo.gdname }}</div>
                        <div class="font_size12">{{ gdInfo.spec_title }}</div>
                        <div v-if="isType == 'kg'" class="font_size12 flex_row">
                            <div class="font_black7 mr10" v-if="gdInfo.price_bw">
                                <span class="mr5"> {{ titleName }}价:</span>
                                <span>￥{{ gdInfo.price_bw || '0.00' }}</span>
                            </div>
                            <div class="font_black7" v-if="gdInfo.price_bw_f && LIMIT_STOREKEEEPER_EDIT_SALE_PRICE">
                                <span class="mr5"> 销售价:</span>
                                <span>￥{{ gdInfo.price_bw_f || '0.00' }}</span>
                            </div>
                        </div>
                    </div>
                </div>
                <div>
                    <template v-if="isType == 'kg'">
                        <div class="obj-info flex_row">
                            <div class="font_size14 ml30">
                                <span class="mr5">共:</span>
                                <span>{{ gdInfo.number || '0' }}</span>
                            </div>
                             <div class="font_size14 ml30">
                                <span class="mr5">已{{ titleName }}:</span>
                                <span>{{ Number(gdInfo.number_inout).toFixed(0) || '0' }}</span>
                            </div>
                            <div class="font_size14 ml30">
                                <span class="mr5">待{{ titleName }}:</span>
                                <span>{{ Number(gdInfo.number_not).toFixed(0) || '0' }}</span>
                            </div>
                        </div>
                    </template>
                    <template v-else>
                        <div class="obj-info flex_row">
                            <div class="bold font_size14 font_red">
                                <span class="mr5">活动价:</span>
                                <span>￥{{ gdInfo.price || '0.00' }}</span>
                            </div>
                            <div class="font_size12 ml30">
                                <span class="mr5">划线价:</span>
                                <span style="text-decoration: line-through;">￥{{ gdInfo.pricec || '0.00'
                                }}</span>
                            </div>
                            <div class="font_size12 ml30">
                                <span class="mr5">数量:</span>
                                <span>{{ gdInfo.number || '0' }}</span>
                                <span v-if="gdInfo.unit_title">（{{ gdInfo.unit_title || '' }}）</span>
                            </div>
                        </div>
                    </template>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref,watch, computed, defineProps, defineEmits } from '@vue/composition-api';
import accessCtrl from "@/js/limit/AccessCtrl.js"; // 检测权限

const props = defineProps({
    // 标题 
    title: {
        type: [String, Number],
        default: '',
    },
    gdInfo: {
        type: Object,
        default: () => ({})
    },
    isType: {
        type: [Number, String],
        default: 'yx' // 默认营销
    },
    tabType: {
        type: [Number, String],
        default: ''
    }
});

const titleName = computed(() => {
    let txt = ''
    if (props.isType == 'kg') {
        txt = props?.tabType == 'into_warehouse' ? '入库' :
            props?.tabType == 'transfer_warehouse' ? '调拨' :
                props?.tabType == 'out_warehouse' ? '出库' : ''
    }
    return txt
})
const emit = defineEmits(['load-more']);
const LIMIT_STOREKEEEPER_EDIT_SALE_PRICE = ref(false); //售价可见
const LIMIT_STOREKEEEPER_EDIT_PURCHASE_PRICE = ref(false); //采购价可见
const initPermission = async () => {
  LIMIT_STOREKEEEPER_EDIT_SALE_PRICE.value =  await accessCtrl.getStorekeeperEditSalePriceLimit(); //售价可见
  LIMIT_STOREKEEEPER_EDIT_PURCHASE_PRICE.value = await accessCtrl.getStorekeeperEditPurchasePriceLimit(); //采购价可见
}
initPermission()

</script>

<style lang="scss" scoped>
div {
    line-height: 1.5 !important;
}

.mb-box-cell {
    padding: 12px 0;
    border-bottom: 1px solid #e2e8f0;
}

.obj-ls-box {
    margin-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 10px;
}

.obj-ls-box:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    border-bottom: none !important;
}

.obj-gdimg-box {
    height: 40px;
    width: 40px;
    border-radius: 2px;
    border: 1px solid #f5f9f9;
    overflow: hidden;
    background-color: #f5f9f9;
}

.obj-avatar {
    height: 100%;
    width: 100%;
    border-radius: 6px;

}
</style>